<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>dom结构</title>
</head>
<body>
<div id="container">

</div>

</body>
<script>

    /*
     * dom结构
     *   1. 添加
     *       appendChild  push
     *       insertBefore unshift
     *  2. 移除
     *       removeChild
     *  3. 替换
     *       replaceChild
    * */

    var container = document.getElementById('container');

    var newBox = document.createElement('div');
    newBox.innerText = "new";

    var newBox2 = document.createElement('div');
    newBox2.innerText = "new2";

    container.appendChild(newBox);
   // container.insertBefore(newBox2,newBox);
  //  container.removeChild(newBox);
    container.replaceChild(newBox2,newBox)

</script>
</html>